Skip to content

fix: crash on startup — TwoWay binding on read-only EndurancePercent - #1

Merged
SysAdminDoc merged 1 commit into
SysAdminDoc:mainfrom
an80sPWNstar:fix/endurance-percent-binding-mode
Aug 25, 2026
Merged

fix: crash on startup — TwoWay binding on read-only EndurancePercent#1
SysAdminDoc merged 1 commit into
SysAdminDoc:mainfrom
an80sPWNstar:fix/endurance-percent-binding-mode

Conversation

@an80sPWNstar

Copy link
Copy Markdown

Bug

The app crashes immediately on startup with:

System.InvalidOperationException: A TwoWay or OneWayToSource binding cannot work on
the read-only property 'EndurancePercent' of type 'PartitionPilot.DiskHealthViewModel'.

Root Cause

ProgressBar.Value inherits from RangeBase.ValueProperty, which is registered with BindsTwoWayByDefault=true. The binding {Binding EndurancePercent} in DiskHealthView.xaml is therefore silently promoted to a TwoWay binding. Since EndurancePercent is a computed getter-only property (no setter), WPF throws during window initialization and kills the process.

Fix

Added Mode=OneWay to the binding — one attribute. The ProgressBar displays the computed value; it doesn't need to write back.

Verification

  • Reproduced crash on v0.9.5 (Windows 11, .NET 10 runtime)
  • Applied fix, rebuilt — app launches and runs correctly
  • Tested with and without SMART data available (both paths exercise the binding)

ProgressBar.Value inherits from RangeBase.ValueProperty which has
BindsTwoWayByDefault=true, causing a TwoWay binding on the read-only
EndurancePercent property. This throws InvalidOperationException at
startup, crashing the app before the window renders.

Fixes crash: A TwoWay or OneWayToSource binding cannot work on the
read-only property 'EndurancePercent'
SysAdminDoc added a commit that referenced this pull request Aug 25, 2026
…erties

Scans every view XAML for bindings on dependency properties whose WPF
metadata sets BindsTwoWayByDefault and resolves the binding path against
the conventional view model via reflection. A read-only target without an
explicit Mode=OneWay fails the test, which is the exact condition that
crashed startup via EndurancePercent (PR #1).
@SysAdminDoc
SysAdminDoc merged commit b5eb628 into SysAdminDoc:main Aug 25, 2026
@SysAdminDoc

Copy link
Copy Markdown
Owner

Good catch, and thanks for the clear writeup. Your diagnosis was exactly right: RangeBase.Value binds two way by default and EndurancePercent has no setter. The line had drifted on main since July (the automation name got localized), so I merged your branch locally, kept your commit, and resolved the conflict there. It shipped in v0.9.22 along with a new test that scans every view for default two way bindings aimed at read only viewmodel properties, so this whole class of crash now fails the suite instead of the app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants